﻿using Microsoft.AspNetCore.Mvc.Filters;
using WCS.Infrastructure.Dto.Response.Common;
using WCS.Infrastructure.EFCore;
using WCS.Service.Interface;

namespace WCS.Api.Admin.Filter
{
    public class BaseFilter : ActionFilterAttribute
    {

        protected readonly IConfiguration _configuration;
        protected readonly IUserService _userService;

        public BaseFilter(IConfiguration configuration, IUserService userService)
        {
            _configuration = configuration;
            _userService = userService;
        }

        /// <summary>
        /// 获取当前登录用户
        /// </summary>
        /// <returns></returns>
        protected async Task<ApiResult?> GetCurrentUser(string code)
        {
            return await _userService.GetUserByCodeAsync(code);
        }
    }
}
